package com.sjb.sixteen_journey_backend.controller;


import com.sjb.sixteen_journey_backend.common.R;
import com.sjb.sixteen_journey_backend.entity.HotelTicket;
import com.sjb.sixteen_journey_backend.entity.InsuranceTicket;
import com.sjb.sixteen_journey_backend.service.IInsuranceTicketService;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import java.util.ArrayList;
import java.util.List;

/**
 * 保险理赔晒单表
 *
 * @author jcz
 * @since 2024-07-13
 */
@RestController
@RequestMapping("/insurance-ticket")
public class InsuranceTicketController {

    @Autowired
    private IInsuranceTicketService insuranceTicketService;
    /**
     * 增加保险理赔晒单表
     * @param insuranceTicket
     * @return
     */
    @PostMapping("/addInsuranceTicket")
    public R addInsuranceTicket(@RequestBody @Valid InsuranceTicket insuranceTicket) {
        return insuranceTicketService.addInsuranceTicket(insuranceTicket);
    }
//    @PostMapping("/addInsuranceTicket")
//    public R addInsuranceTicket(@RequestBody InsuranceTicket insuranceTicket, @RequestParam("image") ArrayList<MultipartFile> images) {
//        return insuranceTicketService.addInsuranceTicket(insuranceTicket, images);
//    }

    /**
     * 删除用户的一篇保险理赔晒单
     * @param id
     * @return
     */
    @DeleteMapping("/deleteInsuranceTicketById/{id}")
    public R deleteInsuranceTicketById(@PathVariable("id") Integer id ) {
        return insuranceTicketService.deleteInsuranceTicketById(id);
    }

    /**
     * 获取所有保险理赔晒单
     * @return
     */
    @GetMapping("showAllInsuranceTicket")
    public R<List<InsuranceTicket>> showAllInsuranceTicket(){
        return insuranceTicketService.showAllInsuranceTicket();
    }

    /**
     * 根据晒单id查保险理赔晒单
     * @param id 晒单id
     * @return
     */
    @GetMapping("showAllInsuranceTicketBy/{id}")
    public R showAllTicketByIdAndStatus(@PathVariable("id") Integer id){
        return insuranceTicketService.showAllTicketByIdAndStatus(id,true);
    }


    /**
     * 根据用户id获取所有保险理赔晒单
     * @return
     */
    @GetMapping("showAllInsuranceTicketByUserId")
    public R<List<InsuranceTicket>> showAllInsuranceTicketByUserId(){
        return insuranceTicketService.showAllInsuranceTicketByUserId();
    }


}
